#ifndef __SOCK_H__
#define __SOCK_H__

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>

#define SOCKLISTENNUM 5
class SockOpt
{
public:
	static int Socket()
	{
		return socket(AF_INET, SOCK_STREAM, 0);
	}

	static int Bind(int sockfd, size_t port)
	{
		struct sockaddr_in addr;
		addr.sin_family = AF_INET;
		addr.sin_port = htons(port);
		addr.sin_addr.s_addr = INADDR_ANY;

		return bind(sockfd, (struct sockaddr*)&addr, (socklen_t)sizeof(addr));
	}

	static int SetSockOpt(int sockfd)
	{
		int opt = 1;
		return setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
	}

	static int Listen(int sockfd)
	{
		return listen(sockfd, SOCKLISTENNUM);
	}

	static int Accept(int sockfd, void* addr, void* addlen)
	{
		return accept(sockfd, (struct sockaddr*)addr, (socklen_t*)addlen);
	}

	static ssize_t Recv(int sockfd, void* strCmd, int strlen, int flags)
	{
		ssize_t num = recv(sockfd, strCmd, strlen, flags);
		return num;
	}

	static ssize_t Send(int sockfd, const void* strCmd, int strlen, int flags)
	{
		return send(sockfd, strCmd, strlen, flags);
	}

};


#endif
